#pragma once
#include "WareTypes.h"

BEGIN_WARECOMMON

class CColor32
{
public:
	CColor32() : color(0) {}
	CColor32( uint8 red, uint8 green, uint8 blue ) : r(red), g(green), b(blue), a(0xff) {}
	CColor32( uint8 red, uint8 green, uint8 blue, uint8 alpha ) : r(red), g(green), b(blue), a(alpha) {}
	CColor32( const CColor32& c ) : color( c.color ) {}

	union
	{
		struct
		{
			uint8 b;
			uint8 g;
			uint8 r;
			uint8 a;
		};

		uint32 color;
	};

	inline CColor32 operator+( const CColor32& c ) const
	{
		CColor32 Color( r + c.r, g + c.g, b + c.b, a + c.a );
		return Color;
	}

	inline CColor32 operator*( float32 fFactor ) const
	{
		CColor32 Color(	static_cast<int32>( a * fFactor + 0.5f ),
		static_cast<int32>( r * fFactor + 0.5f ),
		static_cast<int32>( g * fFactor + 0.5f ),
		static_cast<int32>( b * fFactor + 0.5f ) );

		return Color;
	}

	inline CColor32 Lerp( CColor32& c, float32 fPercent ) const
	{
		float32 fRPercent = 1.0f - fPercent;
		CColor32 c1 = (*this) * fRPercent;
		CColor32 c2 = c*fPercent;

		return c1 + c2;
	}

	inline CColor32& operator=( const uint32 uColor )
	{
		color = uColor;
		return *this;
	}

	/// operator=
	inline CColor32& operator=(const CColor32& c )
	{
		color = c.color;
		return *this;
	}

};

END_WARECOMMON